package prolog.fluents;
import java.lang.StringBuffer;
import prolog.terms.{Const => c};
import prolog.terms.{Prog => p1}
import prolog.terms.{Sink => s1};
import prolog.terms.{Term => t1};

/**
  Builds  Fluents from Java
  Streams
*/
class StringSink_(p: => p1 ,val s: => s1,val t: => t1) extends s1,p1("p") {
  protected var buffer:StringBuffer;
  
  def StringSink_(p: => p1){
   
    super.p;
    this.buffer=new StringBuffer();
  }
  
  override def putElement(t:t1):Int = {
    buffer.append(t.toUnquoted());
    1;
  }
  
  override def stop():Unit ={
    buffer=null;
  }
  
  def collect():t1 ={
    new c(buffer.toString());
  }
}

